disk: Check if returned pointer for allocated memory is NULL
authorAlec Brown <alec.r.brown@oracle.com>
Wed, 22 Jan 2025 02:55:11 +0000 (02:55 +0000)
committerMiao Wang <shankerwangmiao@gmail.com>
Sun, 15 Feb 2026 13:50:20 +0000 (13:50 +0000)
commitb42af0ef463ac2b012429017f63dc8f0c122652c
tree177cef78e09b8356a4ea2918106b0bc9db0c8cc0
parentad2ef8daff0c8e5d937a531e10a0f809c2436f03
disk: Check if returned pointer for allocated memory is NULL

When using grub_malloc(), grub_zalloc() or grub_calloc(), these functions can
fail if we are out of memory. After allocating memory we should check if these
functions returned NULL and handle this error if they did.

On the occasion make a NULL check in ATA code more obvious.

Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name disk-Check-if-returned-pointer-for-allocated-memory-is-NU.patch
grub-core/disk/ata.c
grub-core/disk/ieee1275/obdisk.c
grub-core/disk/ldm.c
grub-core/disk/lvm.c
grub-core/disk/memdisk.c